import request from '@/config/axios'

// 作品分类 VO
export interface WorksCatagoryVO {
  id: number // 编号
  categoryName: string // 分类名称
  parentId: number // 父编号
  sort: number // 排序
}

export interface WorksCatagoryTreeVO {
  id: number // 编号
  categoryName: string // 分类名称
  parentId: number // 父编号
}

// 作品分类 API
export const WorksCatagoryApi = {
  // 查询作品分类列表
  getWorksCatagoryList: async (params) => {
    return await request.get({ url: `/td/works-catagory/list`, params })
  },

  // 查询作品分类详情
  getWorksCatagory: async (id: number) => {
    return await request.get({ url: `/td/works-catagory/get?id=` + id })
  },

  // 新增作品分类
  createWorksCatagory: async (data: WorksCatagoryVO) => {
    return await request.post({ url: `/td/works-catagory/create`, data })
  },

  // 修改作品分类
  updateWorksCatagory: async (data: WorksCatagoryVO) => {
    return await request.put({ url: `/td/works-catagory/update`, data })
  },

  // 删除作品分类
  deleteWorksCatagory: async (id: number) => {
    return await request.delete({ url: `/td/works-catagory/delete?id=` + id })
  },

  // 导出作品分类 Excel
  exportWorksCatagory: async (params) => {
    return await request.download({ url: `/td/works-catagory/export-excel`, params })
  },
  //获得作品分类列表 for tree
  getListForTree : async ()=>{
    return await request.get({ url: `/td/works-catagory/list-for-tree`})
  },
  //通过parentId获得作品分类列表
  getListByParentId: async (parentId:number)=>{
    return await request.get({ url: `/td/works-catagory/getWorksCatagoryDOByParentId?parentId=`+parentId})

  }


}
